package com.java.ssm.service.impl;

import com.java.ssm.dao.DispatchrecordDao;
import com.java.ssm.entity.Dispatchrecord;
import com.java.ssm.service.DispatchrecordService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (Dispatchrecord)表服务实现类
 *
 * @author makejava
 * @since 2021-01-21 08:42:17
 */
@Service("dispatchrecordService")
public class DispatchrecordServiceImpl implements DispatchrecordService {
    @Resource
    private DispatchrecordDao dispatchrecordDao;

    /**
     * 通过ID查询单条数据
     *
     * @param dId 主键
     * @return 实例对象
     */
    @Override
    public Dispatchrecord queryById(Integer dId) {
        return this.dispatchrecordDao.queryById(dId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<Dispatchrecord> queryAllByLimit(int offset, int limit) {
        return this.dispatchrecordDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param dispatchrecord 实例对象
     * @return 实例对象
     */
    @Override
    public Dispatchrecord insert(Dispatchrecord dispatchrecord) {
        this.dispatchrecordDao.insert(dispatchrecord);
        return dispatchrecord;
    }

    /**
     * 修改数据
     *
     * @param dispatchrecord 实例对象
     * @return 实例对象
     */
    @Override
    public Dispatchrecord update(Dispatchrecord dispatchrecord) {
        this.dispatchrecordDao.update(dispatchrecord);
        return this.queryById(dispatchrecord.getDId());
    }

    /**
     * 通过主键删除数据
     *
     * @param dId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer dId) {
        return this.dispatchrecordDao.deleteById(dId) > 0;
    }
}